package cn.ffcs.businessrequest.service;

import java.io.File;
import java.util.HashMap;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

import cn.ffcs.bpm.dao.ProcessConfigDAO;
import cn.ffcs.bpm.dao.TransactProcessStatusDAO;
import cn.ffcs.bpm.dao.TransactorDAO;
import cn.ffcs.bpm.service.BizProcessManageService;
import cn.ffcs.businessrequest.dao.BusinessRequestDAO;
import cn.ffcs.businessrequest.dao.IDocContentDAO;
import cn.ffcs.businessrequest.dao.IReqDocuDAO;
import cn.ffcs.businessrequest.dao.IReqProAttachDAO;
import cn.ffcs.businessrequest.dao.IReqProgressDAO;
import cn.ffcs.businessrequest.model.BusinessRequest;
import cn.ffcs.businessrequest.model.DocContent;
import cn.ffcs.businessrequest.model.ReqDelay;
import cn.ffcs.businessrequest.model.ReqDocu;
import cn.ffcs.businessrequest.model.ReqProgAttach;
import cn.ffcs.businessrequest.model.ReqProgress;
import cn.ffcs.base.service.BaseService;
import cn.ffcs.common.dao.AttachDAO;
import cn.ffcs.common.dao.IAttachDAO;
import cn.ffcs.common.model.Attach;

/**
 * 业务需求交互单服务层<br/>
 * <table>
 * <tr>
 * <td>负责人/principal:</td>
 * <td colspan="2">pany</td>
 * <tr>
 * <td>修改记录/revision:</td>
 * <td colspan="2"></td>
 * </tr>
 * <tr>
 * <td>日期:</td>
 * <td>修改人:</td>
 * <td>修改说明:</td>
 * </tr>
 * <tr>
 * <td></td>
 * <td></td>
 * <td></td>
 * </tr>
 * </table>
 * @author huangjj
 * @version $Id$
 */
public class ReqDelayService<D extends ReqDelay> extends
        BizProcessManageService<D> implements IReqDelayService<D>
{
    private static final int BUFFER_SIZE = 512 * 1024;

    /**
     * 需求延迟DAO
     */
    private cn.ffcs.businessrequest.dao.IReqDelayDAO<ReqDelay> reqDelayDAO;
    

    private BusinessRequestDAO businessRequestDAO;

    /**
     * 保存需求延迟信息操作
     */
    @SuppressWarnings("unchecked")
    public boolean saveReqProgress(D reqProgress, List<File> uploads)
    {

        // 保存延迟信息数据

        try
        {
        reqDelayDAO.save(reqProgress);
        
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    
    /**
     * 删除操作
     * @param baseEntity
     */
    public void remove(D businessRequest)
    {
//        if (businessRequest != null)
//        {
//            Criterion cond1 = Restrictions.eq("refEntity", businessRequest
//                    .getClass().getName());
//            Criterion cond2 = Restrictions.eq("refEntityId", businessRequest
//                    .getId().toString());
//            Criterion condAttach = Restrictions.and(cond1, cond2);
//            List<ReqDocu> reqDocus = reqDocuDAO.findBy(condAttach);
//            for (ReqDocu att : reqDocus)
//            {
//                reqDocuDAO.deleteById(att.getId() + "");
//            }
//            super.remove(businessRequest);
//        }
    }

    public BusinessRequestDAO getBusinessRequestDAO()
    {
        return businessRequestDAO;
    }

    public void setBusinessRequestDAO(BusinessRequestDAO businessRequestDAO)
    {
        this.businessRequestDAO = businessRequestDAO;
    }


    public cn.ffcs.businessrequest.dao.IReqDelayDAO<ReqDelay> getReqDelayDAO()
    {
        return reqDelayDAO;
    }


    public void setReqDelayDAO(
            cn.ffcs.businessrequest.dao.IReqDelayDAO<ReqDelay> reqDelayDAO)
    {
        this.reqDelayDAO = reqDelayDAO;
    }

}
